package Poker;

import java.util.LinkedList;
import java.util.Random;

public class Poker {
	String color;//花色
	
	int  num; //点数
	
	public Poker(String color,int num) {
		this.color =color;
		this.num = num;
	}

	@Override
	public String toString() {
		return "Poker [color=" + color + ", num=" + num + "]";
	}
	
	public static LinkedList createPoker() {
		//该集合用于存储扑克对象
		LinkedList pokers = new LinkedList();
		
		//生成一副扑克牌
		String[] colors= {"A","B","C","D"};
		int[] nums = {1,2,3,4,5,6,7,8,9,10,11,12,13,14};
		
		for(int i=0;i<colors.length;i++) {
			for(int j = 0;j<nums.length;j++) {
				pokers.add(new Poker(colors[i],nums[j]));
			}
		}
		return pokers;
	}
	
	//洗牌功能
	public static void shufflePoker(LinkedList pokers){
        //创建随机数对象
        Random random = new Random();
        for(int i=0; i<100; i++){
        	//随机产生两个索引值
        	int index1 = random.nextInt(pokers.size());
        	int index2 = random.nextInt(pokers.size());
        	//根据索引值取出两张牌 然后交换两张牌的顺序
        	Poker poker1 = (Poker) pokers.get(index1);
        	Poker poker2 = (Poker) pokers.get(index2);
        	pokers.set(index1, poker2);
        	pokers.set(index2, poker1);
        	}
}
	
	//显示扑克牌
	public static void showPoker(LinkedList pokers){
		for(int i=0; i<pokers.size(); i++){
			System.out.print(pokers.get(i) + ";");
			if((i+1)%13==0){
			System.out.println();
			}
		}
	}
	
	//电脑抽出两组五张牌
	public static void show_two_group_Poker(LinkedList pokers) {
		for(int i=0;i<10;i++) {
			System.out.print(pokers.get(i)+";");
			if((i+1)%5==0) {
				System.out.println();
			}
		}
	}
	
}
